<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="/static/common/taglib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>车次管理</title>
    <%@include file="../../public/commonCss.jsp" %>
    <%@include file="../../public/commonJs.jsp" %>
</head>
<body ms-controller="main">
<div id="wrapper">
    <div class="boxmain whiteBox lrbox">
        <div class="lrboxleft borderR" style="width:100%">
            <div class="from-header borderB contentbox">
                <div>
                    <span class="font14"> 所属分类:</span><span class="fontOrange2">部门列表</span>
                </div>
            </div>
            <div class="from-body withheader contentbox" style=" overflow: auto;height:75%">
                <table style="width:100%;" cellpadding="5" cellspacing="0" border="0" class="tableStyle">
                    <thead>
                    <tr align="center">
                        <th>行号</th>
                        <th>部门编号</th>
                        <th>部门名称</th>
                        <th>选择</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr align="center" ms-repeat="tableData">
                        <td>{{$index+1}}</td>
                        <td>{{el.itemValue}}</td>
                        <td>{{el.itemText}}</td>
                        <td>
                            <div class="tableText">
                                <button class="button" ms-on-click-1="$remove" ms-on-click="selectThis(el)">选择
                                </button>
                            </div>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <!-- 分页 -->
                <div id="demo" class="fenye">
                </div>
            </div>
            <div class="bottomButton moveArea" style="display:block;position:absolute;bottom:0;">
                <button class="button blueButton" ms-on-click="saveAll()">保存</button>
                <button class="button" ms-on-click="closeLayer()">取消</button>
            </div>
        </div>
    </div>
    <!-- whitebox -->
</div>
<script type="text/javascript">
    var vm;
    $(function () {
        vm = avalon.define({
            $id: "main",
            tableData: [],//表格数据
            selectDeps: [],
        });
        loadTableData();
    });
    function loadTableData() {
        $.ajax({
            type: 'post',
            url: '${ctx}/messageController/selectAllDep.action',
            data: "",
            beforeSend: function () {
                index = parent.layer.msg('正在加载数据...', {
                    icon: 16,
                    shade: 0.01
                });
            },
            dataType: "json",
            timeout: 10000,
            success: function (data) {
                parent.layer.close(index);
                vm.tableData = data.datas;
            }
        });
    }
    //选择当前的用户
    function selectThis(el) {
        vm.selectDeps.push(el.$model);
    }
    //保存所有
    function saveAll() {
        closeLayer();
        parent.vm.deps = vm.selectDeps;
    }
    //关闭对话框
    function closeLayer() {
        parent.layer.closeAll();
    }
</script>
</body>
</html>